define([
        'app/utils/WebUtils',
        'app/service/GeneralServices',
        'underscore',
        'app/utils/AMUICookieUtils',
        'app/utils/CommonUtils'
        
        
        ], function (
        WebUtils,
        gs,
        _,
        AMUICookieUtils
    ) {
	
	var opt ={};
	
	AMUICookieUtils.clearCookie();
	
	$(".wjt-login-btn").click(function(){
		
		var email = $.val_trim( $("#doc-ipt-email-1").val());
		var pwd = $.val_trim( $("#doc-ipt-pwd-1").val());
		
//		if(!$.isEmail(email)){
//			if(email != "sa"){
//				WebUtils.alert("请正确输入邮件地址");
//				return;				
//			}
//
//		}
		
		var p = {
			email:email,
			pwd:pwd
		};
		gs.doLogin(p, function(resp){
			if(resp.status == "500"){
				if($.isNullStr(resp.result)){
					WebUtils.alert("登录失败，请重试");
				}else{
					WebUtils.alert(resp.result);
				}
			}else{
				var useruuid = resp.result.useruuid;
				var username = resp.result.username;
				var isAdmin = resp.result.isAdmin;
				var p={
					useruuid:useruuid,
					username:username,
					isAdmin:isAdmin
				};
				
				AMUICookieUtils.login(p);
				if(p.isAdmin == "1"){
					$.redirectTo("admin-setting.html");	
				}else{
					$.redirectTo("admin-index.html");	
				}
				
				
			}
		});
		
		
	});
	
	return;
});